//
//  YWShowRuleCell.m
//  maintain
//
//  Created by Kyo on 16/5/13.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWShowRuleCell.h"
#import "YWMacro.h"
#import "YWCommonTool.h"

@interface YWShowRuleCell ()
@property (nonatomic, weak) UILabel *contentLabel;
@end
@implementation YWShowRuleCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"YWShowRuleCellIdentifier";
    YWShowRuleCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[YWShowRuleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentLabel.hidden = NO;
    }
    return self;
}
- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.font = kContentFont;
        label.numberOfLines = 0;
        [self.contentView addSubview:label];
        _contentLabel = label;
    }
    return _contentLabel;
}
-(void)setContent:(NSString *)content{
    self.contentLabel.text = content;
    CGFloat cellWidth = (SCREEN_WIDTH * 0.8) - 16 - 15*2;
    CGFloat height = [YWCommonTool getHeightOfLabel:content andWidth:cellWidth andFont:kContentFont andMinHeight:30];
    self.contentLabel.frame = CGRectMake(15, 5, (SCREEN_WIDTH * 0.8) - 16 - 15*2, height);
}
+ (CGFloat)cellHeightOfContent:(NSString *)content{
    CGFloat cellWidth = (SCREEN_WIDTH * 0.8) - 16 - 15*2;
    CGFloat rowH = [YWCommonTool getHeightOfLabel:content andWidth:cellWidth andFont:kContentFont andMinHeight:30] + 10;
    return rowH;
}
@end
